home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / bin / pilfont.py < prev    next >
Encoding:
Python Source  |  2010-07-26  |  980 b   |  57 lines

  1. #! /usr/bin/python
  2.  
  3. #
  4. # The Python Imaging Library
  5. # $Id$
  6. #
  7. # PIL raster font compiler
  8. #
  9. # history:
  10. # 1997-08-25 fl   created
  11. # 2002-03-10 fl   use "from PIL import"
  12. #
  13.  
  14. VERSION = "0.4"
  15.  
  16. import site
  17. import glob, os, sys
  18.  
  19. # drivers
  20. from PIL import BdfFontFile
  21. from PIL import PcfFontFile
  22.  
  23. if len(sys.argv) <= 1:
  24.     print "PILFONT", VERSION, "-- PIL font compiler."
  25.     print
  26.     print "Usage: pilfont fontfiles..."
  27.     print
  28.     print "Convert given font files to the PIL raster font format."
  29.     print "This version of pilfont supports X BDF and PCF fonts."
  30.     sys.exit(1)
  31.  
  32. files = []
  33. for f in sys.argv[1:]:
  34.     files = files + glob.glob(f)
  35.  
  36. for f in files:
  37.  
  38.     print f + "...",
  39.  
  40.     try:
  41.  
  42.         fp = open(f, "rb")
  43.  
  44.         try:
  45.             p = PcfFontFile.PcfFontFile(fp)
  46.         except SyntaxError:
  47.             fp.seek(0)
  48.             p = BdfFontFile.BdfFontFile(fp)
  49.  
  50.         p.save(f)
  51.  
  52.     except (SyntaxError, IOError):
  53.         print "failed"
  54.  
  55.     else:
  56.         print "OK"
  57.